a = []
k = 0
s = input()
for i in s:
    if i == '(' or i == '[' or i == '{' or i == '<':
        a.append(i)
    else:
        if len(a) != 0:
            b = a.pop(-1)
            if i == ')' and b == '(':
                continue
            else:
                k = 1
                print('False')
                break
            if i == ']' and b == '[':
                continue
            else:
                k = 1
                print('False')
                break
            if i == '}' and b == '{':
                continue
            else:
                k = 1
                print('False')
                break
            if i == ">" and b == "<":
                continue
            else:
                k = 1
                print('False')
                break
        else:
            print('False')
            break
if len(a) != 0:
    print('False')
if k:
    print('True')